﻿<%@page import="com.hh.bss.util.StringHelper" %>
<%
  String custId=request.getParameter("custId");    
  if (StringHelper.isEmpty(custId)) custId="0";
  
%>  
<script>

  var custId=<%=custId%>;
</script> 

	
<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="客户财务信息">  
    <meta name="description" content="客户财务信息">  
    <title>客户财务信息管理</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>

</head>  
<body>  
    
      
    <table id="dg" title="客户银行帐户管理" style="width:1100px;height:250px"  
            url="/customer/customerBankAccount/list.do?custId=<%=custId%>"  
            toolbar="#toolbar" pagination="true"  
            rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false">  

    </table>  
    <table id="dg-Contract" title="客户合同" style="width:1100px;height:250px"  
            url="/customer/customerContract/list.do?custId=<%=custId%>"  
            
            rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false">  
            
    </table> 
    <table id="dg-pn" title="账单" style="width:1100px;height:250px"  
            url="/project/accountPn/list.do"  
             
            rownumbers="true" fitColumns="true" loadMsg="正在查询,请稍候..." singleSelect="false">  

    </table>
    <div id="toolbar">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">新增</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="edit()">修改</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deletes()">删除</a>  
       
    </div>  
    <!-- edit form窗体（开始） -->  
    <div id="dlg" style="display:none;"> 
    	  <!--
        <form id="fm" method="post" novalidate>  
        	  	  	 <input type="hidden" name="id" > 
        	  	  	 <input type="hidden" name="custId" > 
	        		     	        		     
	        		     <div class="fitem">  
                     <label style="width:100px">开户行<font color="red">*</font>:</label>                                            
                     <input name="bankName" class="easyui-box easyui-validatebox"  required="true">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">账户名<font color="red">*</font>:</label>                                            
                     <input name="accountName" class="easyui-box easyui-validatebox"  required="true">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">帐号<font color="red">*</font>:</label>                                            
                     <input name="accountNo" class="easyui-box easyui-validatebox"  required="true">                       
                   </div> 
	        		     <div class="fitem">  
                     <label style="width:100px">备注:</label>                                                                 
                     <textarea name="comment" style="height:60px;width:90%"></textarea>                    
                   </div> 
	        		     
        </form>  
        -->
    </div>  
    <!-- edit form窗体（结束） -->  
  
    <div id="dlg-buttons">  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="save()">Save</a>  
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">关闭</a>  
    </div>  
  
    <script type="text/javascript">  
        var url;  
        
        var optWin = $.window({
		       		 title:"新增客户银行帐户",
		       		 tplRef:"dlg",//这个属性指定模板id
		       		 height:200,		       		 
		       		 closed:true,		       		 
		       		 onComplete:function(){
		       		 	  //窗口里面的初始化,最好是在这个事件里面进行
		       		 	  var curWin=this;
		       		 	  var doForm=curWin.find('#fm');
		       		 	  curWin.doForm=doForm;
		       		 	  this.find("#btn-close").click(function(){		       		 	  	
		       		 	  	   curWin.window('close');
		       		 	  });
		       		 	  this.find("#btn-save").click(function(){		       		 	  	
		                 		  if (!doForm.form('validate')) return;
		                 		  
		                 		  doForm.form('submit',{  
                            url: curWin.url,  
                            onSubmit: function(){                              	  
                                return doForm.form('validate');  
                            },  
                            success: function(result){  
                                var result = eval('('+result+')');                      
                                if (result.success == true){  
                                    //$.messager.alert('信息',result.msg,'info');  
                                    alert(result.msg);
                                    curWin.window('close');
                                    curWin.openWin.reload();
                                    
                                } else {  
                                    //$.messager.alert('错误',result.msg,'error');
                                    alert(result.msg);
                                }  
                            }  
                       }); 		 
		              });
		       		   
		       		 }
		    });
        function add(){         	 
            //$('#dlg').dialog('open').dialog('setTitle','新增客户银行帐户');  
            //$('#fm').form('clear');  
            //$('#fm input[name="custId"]').attr("value",custId);
            //url = '/customer/customerBankAccount/save.do';  
            
            optWin.window('open'); 
            optWin.openWin=window;    
            optWin.url='/customer/customerBankAccount/save.do';
            optWin.doForm.form('clear');
            optWin.doForm.find('input[name="custId"]').attr("value",custId);
            optWin.window('setTitle','新增客户银行帐户');
        }  
        function edit(){  
            //var row = $('#dg').datagrid('getSelected');  
            var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要修改的行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            if (rows){  
                //$('#dlg').dialog('open').dialog('setTitle','修改客户银行帐户');  
                //$('#fm').form('load',rows[0]);  
                //$('#fm').form('load','/customer/customerBankAccount/get.do?id='+rows[0].id);  
                //url = '/customer/customerBankAccount/update.do';
                
                optWin.window('open'); 
                optWin.openWin=window;    
                optWin.url='/customer/customerBankAccount/update.do';
                optWin.doForm.form('clear');                
                optWin.window('setTitle','修改客户银行帐户');
                optWin.doForm.form('load','/customer/customerBankAccount/get.do?id='+rows[0].id);             
            }  
        }  
        function save(){          	   
        	  if (!$('#fm').form('validate')) return; 
            $('#fm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');                      
                    if (result.success == true){  
                        $.messager.alert('信息',result.msg,'info');  
                        $('#dlg').dialog('close');      // close the dialog  
                        $('#dg').datagrid('reload');    // reload the user data  
                    } else {  
                        $.messager.alert('错误',result.msg,'error');
                    }  
                }  
            });  
        }  
        function deletes(){  
            var row = $('#dg').datagrid('getSelected');  
            
            var rows = $('#dg').datagrid('getSelections');  

            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要删除的行','info');
            	 return;
            }
            if (rows){  
                $.messager.confirm('重要提示','确定要删除?',function(r){  
                    if (r){  
                        $.post('/customer/customerBankAccount/delete.do',{ids:getRecordArray(rows,'id').join(',')},function(result){  
                            if (result.success){  
                                $('#dg').datagrid('reload');    // reload the user data  
                            } else {  
                                 
                                $.messager.alert('错误',result.errorMsg,'error'); 
                            }  
                        },'json');  
                    }  
                });  
            }  
        }  
        function find(){  
              
                $('#dlg_query').dialog('open').dialog('setTitle','查询');  
                
                url = '/customer/customerBankAccount/list.do';  
              
        } 
        	
        function query(){  
                
                //var aa=$('#fm_query').formSerialize();
                var formdata=$('#fm_query').formToArray();
                //var dd= JSON.stringify(cc); 
                
                if (!$('#fm_query').form('validate')) return; 
                $('#dg').datagrid({
	                  queryParams: array2json(formdata)
                });
               $('#dlg_query').dialog('close');
              
        }
        
        //生成grid的字段,需要字典的自动转换
        $('#dg').datagrid({
        	   columns:[[        	   	        	   	   
        	   	   {field:'bankName',title:'开户行', width:100}
        	   	   ,{field:'accountName',title:'账户名', width:100}
        	   	   ,{field:'accountNo',title:'帐号', width:100}
        	   	   ,{field:'comment',title:'备注', width:100}
        	   	   ,{field:'creator',title:'创建人', width:100}
        	   	   ,{field:'createDt',title:'创建时间', width:100}
        	   	   ,{field:'modifier',title:'修改人', width:100}
        	   	   ,{field:'modifiedDt',title:'修改时间', width:100}        	   	        	   	
        	   ]]
        	   ,onDblClickRow: function(rowIndex, rowData){
        	    	$('#dlg').dialog('open').dialog('setTitle','修改客户银行帐户');                  
                $('#fm').form('load','/customer/customerBankAccount/get.do?id='+rowData.id);  
                url = '/customer/customerBankAccount/update.do';        	    	
        	    }
        }); 
        //完成-生成grid的字段
        
       
       $('#dg-Contract').datagrid({
        	   columns:[[        	   	
        	   	   {field:'nbr',title:'合同编号', width:100}        	   	   
        	   	   ,{field:'title',title:'title', width:100}
        	   	   ,{field:'contractStyle',title:'合同格式', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('ContractStyle', value);
        	   		      }
        	   	     }
        	   	   ,{field:'contractType',title:'合同类型', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('ContractType', value);
        	   		      }
        	   	     }
        	   	   ,{field:'lang',title:'合同语种', width:100}
        	   	   ,{field:'arRate',title:'合同费率', width:100}
        	   	   ,{field:'minAr',title:'最低收费', width:100,hidden:true}
        	   	   ,{field:'beginD',title:'合同开始日期', width:100}
        	   	   ,{field:'endD',title:'合同结束日期', width:100}
        	   	   ,{field:'arD',title:'付款时间', width:100}
        	   	   ,{field:'preAr',title:'预付款', width:100}
        	   	   ,{field:'preArD',title:'预付款时间', width:100}
        	   	   ,{field:'preUnit',title:'预付款单位', width:100}
        	   	   ,{field:'trialMonths',title:'保证期(试用期)', width:100,hidden:true}
        	   	   ,{field:'refundRate',title:'退款比例', width:100}
        	   	   ,{field:'delayRate',title:'滞纳金比例', width:100}
        	   	   ,{field:'searchLimit',title:'其他特别条款', width:100,hidden:true}
        	   	   ,{field:'comment',title:'其他备注', width:100,hidden:true}
        	   	           	   	        	   	
        	   ]]
        	   
        });        
        
        $('#dg-pn').datagrid({
        	   columns:[[        	   	        	   	   
        	   	   {field:'nbr',title:'PN编号', width:100}
        	   	   ,{field:'finalAr',title:'offer收款金额', width:100}
        	   	   ,{field:'currency',title:'货币单位', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('MoneyType', value);
        	   		      }
        	   	     }        	   	           	   	   
        	   	   ,{field:'status',title:'账单状态', width:100,
        	   		      formatter: function(value,row,index){
        	   		      	return __getConstantCategoryCodeValue('AccountPnStatus', value);
        	   		      },hidden:true
        	   	     }
        	   	   ,{field:'exportDoc',title:'系统自动输出的PN文件', width:100,hidden:true}
        	   	   ,{field:'uploadDoc',title:'直接上传的PN文件', width:100,hidden:true}
        	   	   ,{field:'sendDt',title:'发出时间', width:100}
        	   	   ,{field:'sender',title:'发送人帐号', width:100,hidden:true}
        	   	   ,{field:'comment',title:'备注', width:100,hidden:true}
        	   	   ,{field:'creator',title:'creator', width:100,hidden:true}
        	   	   ,{field:'createDt',title:'录入时间', width:100}
        	   	  
        	   	
        	   	
        	   ]]
        	   ,onDblClickRow: function(rowIndex, rowData){
        	    	$('#dlg').dialog('open').dialog('setTitle','修改账单');                  
                $('#fm').form('load','/project/accountPn/get.do?id='+rowData.id);  
                url = '/project/accountPn/update.do';        	    	
        	    }
        });
        
    </script>  
     
     

     
     
     
</body>  
</html>